﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Threading.Tasks;

namespace ChineseCheselrm1
{
    /// <summary>
    /// 块的字状态
    /// </summary>
    enum Blockstatus
    {
        //棋子的字
        车,
        马,
        象,
        士,
        帅,
        炮,
        兵,
        空
    }
    /// <summary>
    /// 块的颜色状态
    /// </summary>
    enum Gameside
    {
        //棋子的红黑
        红,
        黑
    }
    /// <summary>
    /// 块对象
    /// </summary>
    class Block
    {
        /// <summary>
        /// 定义block的块字属性
        /// </summary>
        public Blockstatus Status { get; set; }
        /// <summary>
        /// 定义block的块颜色属性
        /// </summary>
        public Gameside Side { get; set; }
        /// <summary>
        /// 定义block的rectangle
        /// </summary>
        public Rectangle Rec { get; set; }
        /// <summary>
        /// 定义block的被点击属性
        /// </summary>
        public Boolean IsSelect { get; set; }
        /// <summary>
        /// 定义block的放开鼠标的属性
        /// </summary>
        public Boolean UpSelect { get; set; }
        /// <summary>
        /// 矩阵坐标
        /// </summary>
        public Point Point { get; set; }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="point"></param>
        public Block(Gameside side, Blockstatus status, Rectangle rec, Point point)
        {
            //初始化为空白
            Side = side;
            Status = Blockstatus.空;
            Rec = rec;
            Point = point;
            IsSelect = false;
            UpSelect = false;
        }

        /// <summary>
        /// 画出当前棋子
        /// </summary>
        /// <param name="g">绘图句柄</param>
        /// <param name="rec">当前block的rectangle</param>
        public void Draw(Graphics g)
        {
            if (Status != Blockstatus.空)
            {
                //调用资源文件
                Image img = (Image)Properties.Resources.ResourceManager
               .GetObject(Side.ToString() + Status.ToString());
                g.DrawImage(img, Rec);
                //画点击和没有被点击的时候的方框
                if (IsSelect)
                {
                    //被点击
                    g.DrawRectangle(new Pen(Color.Red, 5), Rec);
                }
                if (UpSelect)
                {
                    //被放开
                    g.DrawRectangle(new Pen(Color.Green,5), Rec);
                }
            }

          }
       
    }
}

